<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<th:block th:fragment="nav2(index)">
    <h4>参数index=[[${index}]]</h4>
    <ul>
        <li th:class="${index == 1 ? 'current' : ''}">主页</li>
        <li th:class="${index == 2 ? 'current' : ''}">登录</li>
        <li th:class="${index == 3 ? 'current' : ''}">注册</li>
        <li th:class="${index == 4 ? 'current' : ''}">商品</li>
        <li th:class="${index == 5 ? 'current' : ''}">关于我们</li>
    </ul>
</th:block>


<th:block th:fragment="nav3(index, name)">
    <th:block th:if="${name} != null">
        <h4>欢迎回来：[[${name}]]</h4>
    </th:block>
    <ul>
        <li th:class="${index == 1 ? 'current' : ''}">主页</li>
        <li th:class="${index == 2 ? 'current' : ''}">登录</li>
        <li th:class="${index == 3 ? 'current' : ''}">注册</li>
        <li th:class="${index == 4 ? 'current' : ''}">商品</li>
        <li th:class="${index == 5 ? 'current' : ''}">关于我们</li>
    </ul>
</th:block>